#include <sstream>
#include "util/StringUtil.h"

using namespace std;

vector<string> StringUtil::split(string text, char delimiter) {
	vector<string> tokens;
	stringstream stream(text);
	string token;

	while (getline(stream, token, delimiter)) {
		tokens.push_back(token);
	}

	return tokens;
}

string StringUtil::trim(string s) {
	return ltrim(rtrim(s));
}

string StringUtil::ltrim(string s) {
	string::size_type pos = s.find_first_not_of(" \f\n\r\t\v");
	s.erase(0, pos);
	return s;
}

string StringUtil::rtrim(string s) {
	string::size_type pos = s.find_last_not_of(" \f\n\r\t\v");
	s.erase(pos + 1);
	return s;
}
